BUILDDIR:=build
DISTDIR:=dist
REVISION:=$(shell grep lastUpdated tei-zotero-translator.js | sed -e "s/^.*\"\([0-9]*-[0-9]*-[0-9]*\) .*/\1/")
DISTFILE:=$(DISTDIR)/tei-zotero-translator-$(REVISION).xpi
SOURCES:=tei-zotero-translator.js



all: dirs zip

dirs:
	mkdir -p $(BUILDDIR)
	mkdir -p $(DISTDIR)

zip: $(DISTFILE)



$(DISTFILE): $(SOURCES)
	cp -r firefox/* build/
	cp tei-zotero-translator.js build/zotero/translators/
	bash -c "cd build && zip -r -x*/*.svn/* ../$(DISTFILE) * && cd -"

clean:
	rm -rf $(BUILDDIR) $(DISTDIR)



.PHONY: all dirs clean